﻿using UnityEngine;
using System.Collections;
using System.IO;


public class CHighScore : CScore
{
    public override void StartGame()
    {
        FileStream fScoreStream = CGlobalMgr.Instance.FileMgr.OpenFile(GlobalDefine.g_strHighScoreFileName, FileAccess.Read);
        if (null != fScoreStream)
        {
            BinaryReader reader = new BinaryReader(fScoreStream);
            m_nDefaultScore = reader.ReadInt32();
            reader.Close();
            CGlobalMgr.Instance.FileMgr.CloseFile(fScoreStream);
        }
       // Debug.Log("HighScore : " + m_nDefaultScore.ToString());
        base.StartGame();
    }

    //가장 높은 점수일경우 파일 업데이트
    public void UpdateHighScoreFile(int nCurScore)
    {
        if (nCurScore > m_nCurScore)
        {
            FileStream fScoreStream = CGlobalMgr.Instance.FileMgr.OpenFile(GlobalDefine.g_strHighScoreFileName, FileAccess.Write);
            if (null != fScoreStream)
            {
                BinaryWriter writer = new BinaryWriter(fScoreStream);
                writer.Write(nCurScore);
                writer.Close();
                CGlobalMgr.Instance.FileMgr.CloseFile(fScoreStream);
            }
        }
    }
}

